Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refacto: rewrite VisibleIf Feat: manage LogicalOperator #11

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from

Conversation

mqueb
Copy link
Contributor

@mqueb mqueb commented Jun 28, 2024

here is the new one.

refcto of management of isVisible and more

@mqueb
Copy link
Contributor Author

mqueb commented Jun 28, 2024

damn, u have change things ont it for people not using schema ... will adjust with your modifications

@mqueb
Copy link
Contributor Author

mqueb commented Jun 28, 2024

What i've done.

  • Refacto VisibilityTriggerStorage. vt[modGUID][uiElement] = VisibileIf
  • change visibilityUpdate to detect all uiElement touch by setting update
  • write a update Visibility(modguid, uiElement)
  • manage LogicalOperator !!
  • rewrite your Condition Validation to be done once during manageVisibleIf
  • move operator function be be create once and not at any condition !

@mqueb
Copy link
Contributor Author

mqueb commented Jun 28, 2024

add isVisible operator. use case i need it:

settingX (a intSlider) is visible if settingA > 0 or settingB > 0 or setttingC > 0

SettingZ is visible if settingX > 0 (but if it's visible) so it's a (A>0 or B>0 or C>0) and X>0

Other usage is to make 2 setting share same visiblity without rewrite all conditioning

edit: ready to review, just tell if u want to move every visibility things to a dedicated file

Comment on lines 185 to 191
if v and (logicalOperator == "or") then
visible = true
break
elseif (not v) and (logicalOperator == "and") then
visible = false
break
end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being evaluated in an if statement?

Copy link
Contributor Author

@mqueb mqueb Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of the break to stop looping all condition and stop as soon as possible.
"and" have true initial value and turn false if one condition is false -> break
"or" have false initial value and turn true if one condition is true -> break

no need to test more conditions. so break needed . it's not a simple assigment

Comment on lines 23 to 31
operators = {
["=="] = function(a, b) return a == b end,
["!="] = function(a, b) return a ~= b end,
["<="] = function(a, b) return a <= b end,
[">="] = function(a, b) return a >= b end,
["<"] = function(a, b) return a < b end,
[">"] = function(a, b) return a > b end,
["isVisible"] = function(a, b) return a == b end
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this shouldn't be in the IMGUILayer class

Copy link
Contributor Author

@mqueb mqueb Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's why i said it need a visibilityManager class. I move them here to avoid recreating them at each condition and use CPU for nothing

[">"] = function(a, b) return a > b end,
["isVisible"] = function(a, b) return a == b end
},
uiElementByName = {}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the idea of attaching more lookup stuff to the class... we haven't been needing to do this

Copy link
Contributor Author

@mqueb mqueb Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i write exemple of the requierement of that. test value is a fact, but if widget or section is invisible, the widget value a no meaning. i use VisibleIf operator to avoid MCM to check visibility of parent. and make user responsible to check it depending of what he have make.
uiElementByName is the simpliest way to achieve retrieve it without tons of looping and CPU. doing the map cost nothing but few byte..
again, just tell to do visibilityManager class

@AtilioA
Copy link
Owner

AtilioA commented Jun 28, 2024

Thank you for your effort on this PR. However, I feel that it adds too much complexity and opens up for technical debt (worsening maintenance) for an issue that has already been largely addressed. I have several mods already, so maintenance is very important to me.

@mqueb
Copy link
Contributor Author

mqueb commented Jun 28, 2024

control over user input is far more maintainble as i write it. and it's done at one place and only once. Currently, it's validated each time, and in multiple method !!! chance of visibilityTrigger storage make it possible.
it's the same with visibilityTrigger storage. it's far more simple than before.
Moreover logicalOperator now work

@mqueb
Copy link
Contributor Author

mqueb commented Jul 1, 2024

rebase and move to other class.

Noting to do with PR but: since my rebase, widget description are now next to le the (on le right). was under before: that was WAY better to read. even on my 34 UW, now it's nearly take all.

end


function IMGUIVisibilityManager:EvaluateVisibleIf(modGUID, visibleIf, elementName)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be local function in manageVisibleIf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants